//
//  ViewController.m
//  测试AFNetworking
//
//  Created by 伍银荣 on 2021/12/19.
//  Copyright © 2021 com.WYR. All rights reserved.
//

#import "ViewController.h"
#import <AFNetworking.h>
#import <SDWebImage.h>
#import "NetworkTools.h"


@interface ViewController ()

@property(nonatomic, weak) UIImageView *imageView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
//    UIImageView *imgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
//    imgView.backgroundColor = [UIColor redColor];
//    [self.view addSubview:imgView];
//
//    self.imageView = imgView;
//
//    [self.imageView sd_setImageWithURL:[NSURL URLWithString:@"https://image.baidu.com/search/detail?ct=503316480&z=0&ipn=d&word=图片&hs=0&pn=1&spn=0&di=97130&pi=0&rn=1&tn=baiduimagedetail&is=0%2C0&ie=utf-8&oe=utf-8&cl=2&lm=-1&cs=978564369%2C3572070486&os=557987270%2C1388204596&simid=3294540410%2C180984192&adpicid=0&lpn=0&ln=30&fr=ala&fm=&sme=&cg=&bdtype=0&oriquery=图片&objurl=https%3A%2F%2Fgimg2.baidu.com%2Fimage_search%2Fsrc%3Dhttp%3A%2F%2Fnimg.ws.126.net%2F%3Furl%3Dhttp%3A%2F%2Fdingyue.ws.126.net%2F2021%2F0628%2F29618e08j00qverj7001ec000ci00loc.jpg%26thumbnail%3D650x2147483647%26quality%3D80%26type%3Djpg%26refer%3Dhttp%3A%2F%2Fnimg.ws.126.net%26app%3D2002%26size%3Df9999%2C10000%26q%3Da80%26n%3D0%26g%3D0n%26fmt%3Djpeg%3Fsec%3D1642574509%26t%3D8de2ad33e8d918ad5c023f5a2325a088&fromurl=ippr_z2C%24qAzdH3FAzdH3F1y_z%26e3B8mn_z%26e3Bv54AzdH3Fw6ptvsjAzdH3F2135kh2aac9m94ke_z%26e3Bip4s&gsm=1&islist=&querylist=&dyTabStr=MCwzLDYsMSw0LDIsNSw3LDgsOQ%3D%3D"]];
    
    
//    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
//    //设置反序列化数据格式
//    manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil];
//    [manager GET:@"http://www.weather.com.cn/data/sk/101010100.html" parameters:nil headers:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//        NSLog(@"Progress - %@", downloadProgress);
//    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
//        NSLog(@"responseObject - %@",responseObject);
//        NSDictionary *info = responseObject[@"weatherinfo"];
//        NSLog(@"info = %@",info);
//        NSString *city = responseObject[@"weatherinfo"][@"city"];
//        NSLog(@"city = %@",city);
//    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
//        NSLog(@"error - %@",error);
//    }];
    
    [[NetworkTools sharedTools]requestWithMethod:GET UrlString:@"data/sk/101010100.html" parameters:nil headers:nil progress:^(NSProgress * _Nonnull downloadProgress) {
        NSLog(@"downloadProgress = %@",downloadProgress);
    } finished:^(id  _Nonnull result, NSError * _Nonnull error) {
        NSLog(@"error = %@",error);
        if (error != nil) {
            return;
        }
        NSLog(@"result = %@",result);
    }];
    
//    [[NetworkTools sharedTools] requestWithUrlString:@"data/sk/101010100.html" parameters:nil headers:nil progress:^(NSProgress * _Nonnull downloadProgress) {
//        NSLog(@"downloadProgress = %@",downloadProgress);
//    } finished:^(id  _Nonnull result, NSError * _Nonnull error) {
//        NSLog(@"error = %@",error);
//        if (error != nil) {
//            return;
//        }
//        NSLog(@"result = %@",result);
//    }];
    
    
}


@end
